package com.tuanzi.loan.web.lazy.statistics.api;

import com.tuanzi.loan.business.service.statistics.ApiFlowStatService;
import com.tuanzi.loan.core.lazy.BaseLazyDataModel;
import com.tuanzi.loan.core.util.SpringContextHolder;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.statistics.api.ApiFlowStatSearchRequest;
import com.tuanzi.loan.vo.response.statistics.api.ApiFlowStatSearchResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;

import java.util.Collections;

/**
 * api统计 ApiFlowStatDataModel
 */
public class ApiFlowStatDataModel extends
        BaseLazyDataModel<ApiFlowStatSearchRequest, ApiFlowStatSearchResponse> {
    private Boolean isFirst = true;

    private ApiFlowStatService apiFlowStatService = SpringContextHolder.getBean(ApiFlowStatService.class);

    public ApiFlowStatDataModel(ApiFlowStatSearchRequest searchRequest) {
        super(searchRequest);
    }

    @Override
    protected Page<ApiFlowStatSearchResponse> doLoad(PageSearcher<ApiFlowStatSearchRequest> pageSearcher) {
//        if (isFirst){
//            isFirst = false;
//            return new PageImpl<>(Collections.emptyList());
//        }
        return apiFlowStatService.list(pageSearcher);
    }
}
